<template >
  <el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
</template>


<script>
export default {
  data() {
    return {
      data: [],
      defaultProps: {
        children: 'children',
        label: 'label'
      }
    };
  },
  methods: {
    getCategoryTree() {
      const _this = this;
      this.$api.CategoryApi.GetCategoryTree().then(res => {
        if (res.Code) {
          _this.data = res.Result;
        }
      })
    },
    handleNodeClick(data) {
      console.log(data);
    }
  },
  mounted() {
    this.getCategoryTree();
  }
};
</script>
